/**
 * 用于将字节数组转换成对象
 */
package com.scpii.universal.generator;

import org.apache.log4j.Logger;

import com.scpii.universal.pb.PbUniversal.PBCMD;
import com.scpii.universal.service.mobile.MobileAppService;
import com.scpii.universal.service.mobile.MobileContentService;
import com.scpii.universal.service.mobile.MobileEnterpService;
import com.scpii.universal.service.mobile.MobileFunctionService;
import com.scpii.universal.service.mobile.MobilePageService;
import com.scpii.universal.service.mobile.MobileUserService;

/**
 * UniversalApi
 * 
 * @author 甘建新 2012-7-11下午10:28:48
 */
public class Generator {
	// private MobileAppService mobileAppService = new MobileAppService();
	// private MobileContentService mobileContentService = new
	// MobileContentService();
	// private MobileEnterpService mobileEnterpService = new
	// MobileEnterpService();
	// private MobileFunctionService mobileFunctionService = new
	// MobileFunctionService();
	// private MobileUserService mobileUserService = new MobileUserService();

	private MobileAppService mobileAppService;
	private MobileContentService mobileContentService;
	private MobileEnterpService mobileEnterpService;
	private MobileFunctionService mobileFunctionService;
	private MobileUserService mobileUserService;
	private MobilePageService mobilePageService;
	//加入日志
	private Logger log = Logger.getLogger(Generator.class);

	/**
	 * @param CMD
	 * @param bytes
	 * @return
	 * @author 甘建新 2012-7-12上午12:20:10
	 */
	public byte[] startGenerate(int CMD, byte[] bytes) {
		if (bytes != null && bytes.length > 0) {
			PBCMD PBCMD_VALUE = PBCMD.valueOf(CMD);
			log.info("命令代码为："+PBCMD_VALUE.toString());
			switch (PBCMD_VALUE) {
			case PbAppCMD:
				return mobileAppService.getApp(bytes);
			case PbAppUpdateCMD:
				return mobileAppService.getAppUpdate(bytes);
			case PbAppPageCatelogCMD:
				return mobileAppService.getAppPage(bytes);
			case PbAppPageContentCMD:
				return mobileAppService.getAppContentPage(bytes);
			case PbAppContentCMD:
				return mobileContentService.getContent(bytes);
			case PbAppContentListCMD:
				return mobileContentService.getContentList(bytes);
			case PbContentCatelogListCMD:
				return mobileContentService.getContentCatelogList(bytes);
			case PbContentImgListCMD:
				return mobileContentService.getContentImgList(bytes);
			case PbFeedbackListCMD:
				return mobileFunctionService.getFeedbackList(bytes);
			case PbAddFeedbackCMD:
				return mobileFunctionService.addFeedback(bytes);
			case PbFavoritesListCMD:
				return mobileFunctionService.getFavoritesList(bytes);
			case PbAddFavoritesCMD:
				return mobileFunctionService.addFavorites(bytes);
			case PbAddShareCMD:
				return mobileFunctionService.addShare(bytes);
			case PbCommentListCMD:
				return mobileFunctionService.getCommentList(bytes);
			case PbAddCommentCMD:
				return mobileFunctionService.addComment(bytes);
			case PbOrderListCMD:
				return mobileFunctionService.getOrderList(bytes);
			case PbOrderCMD:
				return mobileFunctionService.addOrder(bytes);
			case PbEnterpShopListCMD:
				return mobileEnterpService.getEnterpShopList(bytes);
			case PbEnterpWeiboCMD:
				return mobileEnterpService.getEnterpWeibo(bytes);
			case PbMoreContentListCMD:
				return mobileFunctionService.getMoreContentList(bytes);
			case PbPushMessageListCMD:
				return mobileFunctionService.getPushMessageList(bytes);
			case PbDataUpdateCMD:
				return mobileFunctionService.getDataUpdateInterface(bytes);
			case PbUpdateAppLoadingImgCMD:
				return mobileFunctionService.getUpdateAppLoadingImg(bytes);
			case PbUpdateUserCheckCMD:
				return mobileUserService.updateUserInfoCheck(bytes);
			case PbJoinActiveCMD:
				return mobileFunctionService.joinActive(bytes);
			case PbViewCatelogPageCMD:
				return mobilePageService.getViewCatelogListByPageNum(bytes);
			case PbViewContentPageCMD:
				return mobilePageService.getViewContentListByPageNum(bytes);
			case PbPageContentPageCMD:
				return mobilePageService.getPageViewContentList(bytes);
			case PBHouseContentDetailCMD:
				return mobileContentService.getHouseContentDetail(bytes);
			case PBContentSearchCMD:
				return mobileContentService.getContentSearchResult(bytes);
			case PBContentSearchField:
				return mobileContentService.getContentSearchField(bytes);
			case PBShopFilterOptionsCMD:
				return mobileEnterpService.getShopFilterOptions(bytes);
			default:
			}
		}
		return null;
	}

	// Setter
	public void setMobileAppService(MobileAppService mobileAppService) {
		this.mobileAppService = mobileAppService;
	}

	public void setMobileContentService(
			MobileContentService mobileContentService) {
		this.mobileContentService = mobileContentService;
	}

	public void setMobileEnterpService(MobileEnterpService mobileEnterpService) {
		this.mobileEnterpService = mobileEnterpService;
	}

	public void setMobileFunctionService(
			MobileFunctionService mobileFunctionService) {
		this.mobileFunctionService = mobileFunctionService;
	}

	public void setMobileUserService(MobileUserService mobileUserService) {
		this.mobileUserService = mobileUserService;
	}

	public void setMobilePageService(MobilePageService mobilePageService) {
		this.mobilePageService = mobilePageService;
	}
	
}
